﻿using LxBasic;

namespace LxCore
{
    public class FaceNormalField : FieldBase<Vector3d>
    {
        public override IFaceVarArr<Vector3d> GetFaceVarArr(IIndexHost indexHost)
        {
            if (indexHost is FvInner inner)
            {
                return new FaceNormal() { faces = inner.InZone.InnFaces };
            }
            else if (indexHost is FvBound bound)
            {
                return new SideNormal() { faces = bound.InZone.BouFaces };
            }
            else
            {
                throw new InvalidDataException();
            }
        }
        public class FaceNormal : IFaceVarArr<Vector3d>
        {
            public FvInnFace[] faces;
            public Vector3d GetFaceVar(int faceID)
            {
                return faces[faceID].Normal;
            }
        }
        public class SideNormal : IFaceVarArr<Vector3d>
        {
            public FvBouFace[] faces;
            public Vector3d GetFaceVar(int faceID)
            {
                return faces[faceID].Normal;
            }
        }
    }
    //public class VolumnOrAreaProvider : IFieldHost<double>
    //{
    //    public VolumnOrAreaProvider(FvZone fvZone)
    //    {
    //        this.Cells = fvZone.Cells;
    //        this.Faces = fvZone.Faces;
    //    }
    //    FvCell[] Cells;
    //    FvFace[] Faces;
    //    public override double GetCellValue(int cellIndex)
    //    {
    //        return Cells[cellIndex].Volumn;
    //    }
    //    public override double GetFaceValue(int faceIndex)
    //    {
    //        return Faces[faceIndex].Area;
    //    }
    //}
}
